<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="../../include.inc.jsp"%>
<link rel="stylesheet" type="text/css" href="${contextPath}/static/assets/css/bootstrap-datepicker3.css" />
<div class="row">
    <div class="col-lg-12">
        <form id="formDlg" class="form-horizontal" role="form">
            <input type="hidden" id="id" name="id" value="${notice.id}" />
            <!-- 数据权限 -->
            <input type="hidden" id="organizationId" name="organization.id" value="${organizationId}" /> 
            <div class="form-group">
                <label class="col-lg-2 control-label">所属医院:</label><span class="text-danger">*</span>
                <div class="col-lg-9">
                    <input type="hidden" class="form-control" id="hospitalId" name="hospital.id" value="${notice.hospital.id}" />
                    <input type="text" readonly="readonly" class="form-control" id="hospitalName" name="hospitalName" value="${notice.hospital.name}" onclick="selectHospital();"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg-2 control-label">标题:</label><span class="text-danger">*</span>
                <div class="col-lg-9">
                    <input type="text" class="form-control" id="title" name="title" value="${notice.title}" maxlength="60" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg-2 control-label">内容:</label><span class="text-danger">*</span>
                <div class="col-lg-9">
                    <textarea class="form-control" id="content" name="content" maxlength="2000">${notice.content}</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg-2 control-label">优先级:</label><span class="text-danger">*</span>
                <div class="col-lg-9">
                    <input type="number" class="form-control" id="priority" name="priority" value="${notice.priority}" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg-2 control-label">启用时间:</label><span class="text-danger">*</span>
                <div class="col-lg-9">
                    <input type="text" readonly="readonly" class="form-control" id="useTime" name="useTime" value="<fmt:formatDate value="${notice.useTime}" pattern="yyyy-MM-dd HH:mm:ss"/>" />
                </div>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript" src="${contextPath}/static/assets/js/date-time/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="${contextPath}/static/assets/js/date-time/bootstrap-datepicker.zh-CN.js"></script>
<script type="text/javascript">
function selectHospital(){
    var ajaxSelectUrl = contextPath + '/manage/ordering/hospital/select';
    showSelectDlg("选择医院",ajaxSelectUrl,["table-data1"],setSelectValue);
}
function setSelectValue(obj){
    $("#hospitalId").val(obj[0].id);
    $("#hospitalName").val(obj[0].name);
}
jQuery(function($) {
    $("#useTime").datepicker({//日期选择器
        language : "zh-CN",
        format : 'yyyy-mm-dd',
        forceParse : true,
        pickTime : true,
        todayBtn : false,
        autoclose : true,
        minView : '2',
        forceParse : false
    });
	
    $('#formDlg').validate({
        errorElement : 'span',
        errorClass : 'help-block',
        focusCleanup : false,
        focusInvalid : false,
        onsubmit : false,
        rules : {
            "title":{required:true},
            "content":{required:true},
            "priority":{required:true},
            "useTime":{required:true},
            "hospitalName":{required:true}
        },
        messages : {
            "title" : '请输入公告标题',
            "content" : '请输入公告内容',
            "priority" : '请输入优先级',
            "useTime" : '请选择启用时间',
            "hospitalName" : '请选择所属医院',
        },
        highlight : function(e) {
            $(e).closest('.form-group').removeClass('has-info').addClass('has-error');
        },
        success : function(e) {
            $(e).closest('.form-group').removeClass('has-error').addClass('has-success');
            $(e).remove();
        },
    });
});
</script>